{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "是否继续存单词? y/n\n",
      "y\n",
      "请输入你想要存储的单词:\n",
      "eg: Nice to see you\n",
      "test\n",
      "成功存储1个单词\n",
      "是否继续存储单词? y/nn\n",
      "已经存好的单词为:\n",
      " [{'单词': 'test', '解释': ['test']}]\n"
     ]
    }
   ],
   "source": [
    "# 建立词库\n",
    "start = input('是否继续存单词? y/n\\n')\n",
    "wordslst = []\n",
    "while start == 'y':\n",
    "    word = input('请输入你想要存储的单词:\\neg: Nice to see you\\n')\n",
    "    dic = {'单词': word.split(':')[0],'解释': word.split(':')[1]}\n",
    "    wordslst.append(dic)\n",
    "    print('成功存储1个单词')\n",
    "    start = input('是否继续存储单词? y/n')\n",
    "print('已经存好的单词为:\\n',wordslst)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 背\n",
    "import random \n",
    "\n",
    "random.choice(wordslst)\n",
    "\n",
    "s_num = int(input('你想测试几次? \\n'))\n",
    "\n",
    "for i in range(s_num):\n",
    "    w = random.choice(wordslst)\n",
    "    print('该单词意思是',w['解释'])\n",
    "    test = input('请输入单词:\\n')\n",
    "    if test == w['单词']:\n",
    "        print('回答正确\\n')\n",
    "    else:\n",
    "        print('回答错误\\n')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
